package com.sh.datasync.util;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.EasyExcel;
import com.sh.datasync.model.CompareData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @Author: seeTools
 * @Date: 2025/6/21  10:06
 * @Version 1.0
 */
public class ExcelUtils {

    private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class);

    /**
     * 解析EXCEL数据
     */
    public static List<CompareData> analysis() {
        // 读取文件信息
        try {
            ClassPathResource resource = new ClassPathResource("templates/副本中集天达空港.xlsx");
            InputStream inputStream = resource.getInputStream();
            List<CompareData> dataList = EasyExcel.read(inputStream).head(CompareData.class).sheet().doReadSync();
            logger.info("总共:{}", dataList.size());
            if (CollUtil.isNotEmpty(dataList)) {
                return dataList;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
